<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<c:set var="frontPath" value="${redis:getSysConfig('base_path_front')}"/>
<c:set var="srcPath" value="${redis:getSysConfig('sysFileVisitRoot_back')}"/>
<c:set var="uploadPath" value="${redis:getSysConfig('uploadFileVisitRoot')}"/>
<style type="text/css">
#detailContentValue img{
	width:auto;
	max-width:765px;
	height:auto;
}
</style>
<script type="text/javascript">
	function detailInfo(id){
		$.ajax({
            type: "POST",
            url: "${basePath}/back/shopProduct/getProductInfoById.sjson",
            data: {productId:id},
            dataType: "JSON",
            success: function(data){
                var productInfo = data.productRelationMap.productInfo;
                var productImgList = data.productRelationMap.productImgList;
                var productInfoDetail = data.productRelationMap.productInfoDetail;
                /**重置详情页中所有html展示信息**/
                resetDetailTable("detailTable");
                $(".newAdd").remove();
                if(data.shopShopInfo.shopName!=null){
                    $("#dshopName").html(data.shopShopInfo.shopName);
                }else{
                    $("#dshopName").html("/");
                }
                if(data.shopBrand.brandName!=null){
                    $("#dbrandId").html(data.shopBrand.brandName);
                }else{
                    $("#dbrandId").html("/");
                }
                if(data.shopProCategoryName!=null){
                    $("#dshopProCategoryName").html(data.shopProCategoryName);
                }else{
                    $("#dshopProCategoryName").html("/");
                }
                if(productInfo.upRatio!=null){
                    $("#dupRatio").html(productInfo.upRatio+"%");
                }else{
                    $("#dupRatio").html("/");
                }
                if(productInfo.secRatio!=null){
                    $("#dsecRatio").html(productInfo.secRatio+"%");
                }else{
                    $("#dsecRatio").html("/");
                }
                if(productInfo.thiRatio!=null){
                    $("#dthiRatio").html(productInfo.thiRatio+"%");
                }else{
                    $("#dthiRatio").html("/");
                }
                $("#dshopInfoId").val(productInfo.shopInfoId);
                $("#dproductName").html(productInfo.productName);
                $("#dproductFullName").html(productInfo.productFullName);

                if(productInfo.imageType==1 || productInfo.imageType=='1'){
                    $("#dimageType").html("图片");
                }else if(productInfo.imageType==2 || productInfo.imageType=='2'){
                    $("#dimageType").html("视频");
                }

                var backUrl="${uploadPath}/"+productInfo.videoUrl;
                if(productInfo.videoUrl!=null && productInfo.videoUrl!=''){
                    $("#dvideoUrl").hide();
                    $("#a_videoUrl").show();
                    $("#a_videoUrl").attr("href",backUrl);
                }else{
                    $("#dvideoUrl").show();
                    $("#a_videoUrl").hide();
                    $("#dvideoUrl").html("/");
                }

                $("#dtuanPrice").html(productInfo.tuanPrice);
                $("#dmemberPrice").html(productInfo.memberPrice);
                $("#dmarketPrice").html(productInfo.marketPrice);
                $("#salesPriceBack").html(productInfo.salesPriceBack);
                $("#dsalesPrice").html(productInfo.salesPrice);
                $("#dcostPrice").html(productInfo.costPrice);
                $("#dsmallPhoto").html("<img id='uploadImg_detail_1' class='uploadImg' onMouseOver='showDetailBigImage(1,3,3,0)'  onMouseOut='showDetailRebackImage(1,1,1)' src='${uploadPath}/"+productInfo.logoImg+"' onerror='this.src=\"${srcPath}/common/images/mrbj.png\"' width='120px' height='120px' />");
                if(productInfo.createDate!='' && productInfo.createDate != null && productInfo.createDate!=undefined){
                    $("#d_createDate").html(new Date(productInfo.createDate.time).Format("yyyy-MM-dd hh:mm:ss"));
                }else{
                    $("#d_createDate").html("");
                }
                $("#dmeasuringUnitName").html(productInfo.measuringUnitName);

                //$("#virtualCoinNumber").html(productInfo.virtualCoinNumber);
                $("#dgiveAwayCoinNumber").html(productInfo.giveAwayCoinNumber);
                $("#dstoreNumber").html(productInfo.storeNumber);
                $("#dproductId").html(productInfo.productId);

                /**组拼分类名称 begin**/
                var productTypeName;
                if(data.productTypeName.level1Name!=null && data.productTypeName.level1Name !='' && data.productTypeName.level1Name !=undefined){
                    productTypeName=data.productTypeName.level1Name;
                }
                if(data.productTypeName.level2Name!=null && data.productTypeName.level2Name !='' && data.productTypeName.level2Name !=undefined){
                    productTypeName+="&nbsp;&gt;&nbsp;"+data.productTypeName.level2Name;
                }
                if(data.productTypeName.level3Name!=null && data.productTypeName.level3Name !='' && data.productTypeName.level3Name !=undefined){
                    productTypeName+="&nbsp;&gt;&nbsp;"+data.productTypeName.level3Name;
                }
                $("#dproductTypeName").html(productTypeName);/**分类的名称**/
                /**组拼分类名称 end**/

                $("#dqrCode").html("<img id='uploadImg_detail_2' class='uploadImg' onMouseOver='showDetailBigImage(2,3,3,0)'  onMouseOut='showDetailRebackImage(2,1,1)' src='${uploadPath}/"+productInfo.qrCode+"' onerror='this.src=\"${srcPath}/common/images/mrbj.png\"' width='120px' height='120px' />");

                if(productInfo.manufacturerModel!=null&&productInfo.manufacturerModel!=""){
                    $("#dmanufacturerModel").html(productInfo.manufacturerModel);
                }else{
                    $("#dmanufacturerModel").html("/");
                }
                if(productInfo.barCode!=null&&productInfo.barCode!=""){
                    $("#dbarCode").html(productInfo.barCode);
                }else{
                    $("#dbarCode").html("/");
                }
                if(productInfo.auditComment!=null&&productInfo.auditComment!=""){
                    $("#dauditComment").html(productInfo.auditComment);
                }else{
                    $("#dauditComment").html("/");
                }
                if(productInfo.putSaleDate!=null&&productInfo.putSaleDate!=""){
                    $("#dputSaleDate").html(new Date(productInfo.putSaleDate.time).Format("yyyy-MM-dd hh:mm:ss"));
                }else{
                    $("#dputSaleDate").html("/");
                }
                if(productInfo.packingSpecifications!=null&&productInfo.packingSpecifications!=""){
                    $("#dpackingSpecifications").html(productInfo.packingSpecifications);
                }else{
                    $("#dpackingSpecifications").html("/");
                }
                if(productInfo.productCode!=null&&productInfo.productCode!=""){
                    $("#dproductCode").html(productInfo.productCode);
                }else{
                    $("#dproductCode").html("/");
                }
                if(productInfo.sku!=null&&productInfo.sku!=""){
                    $("#dsku").html(productInfo.sku);
                }else{
                    $("#dsku").html("/");
                }
                if(productInfo.updateDate!=null && productInfo.createDate!='' && productInfo.createDate!=undefined){
                    $("#d_updateDate").html(new Date(productInfo.updateDate.time).Format("yyyy-MM-dd hh:mm:ss"));
                }else{
                    $("#d_updateDate").html("");
                }
                if(productInfo.pointConvert!=null&&productInfo.pointConvert!=""){
                    $("#dpointConvert").html(productInfo.pointConvert);
                }else{
                    $("#dpointConvert").html("/");
                }
                if(productInfo.note!=null&&productInfo.note!=""){
                    $("#dnote").html(productInfo.note);
                }else{
                    $("#dnote").html("/");
                }
                if(productInfo.seoTitle!=null&&productInfo.seoTitle!=""){
                    $("#dseoTitle").html(productInfo.seoTitle);
                }else{
                    $("#dseoTitle").html("/");
                }
                if(productInfo.seoKeyWord!=null&&productInfo.seoKeyWord!=""){
                    $("#dseoKeyWord").html(productInfo.seoKeyWord);
                }else{
                    $("#dseoKeyWord").html("/");
                }
                if(productInfo.seoDescription!=null&&productInfo.seoDescription!=""){
                    $("#dseoDescription").html(productInfo.seoDescription);
                }else{
                    $("#dseoDescription").html("/");
                }
                if(productInfo.isPutSale=="1"){
                    $("#ddisPutSale").html("<font class='color_002'>未上架</font>");
                }else if(productInfo.isPutSale=="2"){
                    $("#ddisPutSale").html("<font class='color_001'>已上架</font>");
                }else{
                    $("#ddisPutSale").html("<font class='color_003'>违规下架</font>");
                }
                if(productInfo.isPass=="0"){
                    $("#disPass").html("<font class='color_002'>未通过</font>");
                }else if(productInfo.isPass=="1"){
                    $("#disPass").html("<font class='color_001'>已通过</font>");
                }else if(productInfo.isPass=="2"){
                    $("#disPass").html("<font class='color_004'>待申请</font>");
                }else if(productInfo.isPass=="3"){
                    $("#disPass").html("<font class='color_003'>待审核</font>");
                }
                if(productInfo.isTop=="0"){
                    $("#disTop").html("<font class='color_002'>否</font>");
                }else{
                    $("#disTop").html("<font class='color_001'>是</font>");
                }
                if(productInfo.isNew=="0"){
                    $("#disNew").html("<font class='color_002'>否</font>");
                }else{
                    $("#disNew").html("<font class='color_001'>是/font>");
                }
                if(productInfo.isHot=="0"){
                    $("#disHot").html("<font class='color_002'>否</font>");
                }else{
                    $("#disHot").html("<font class='color_001'>是</font>");
                }
                if(productInfo.isRecommend=="0"){
                    $("#disRecommend").html("<font class='color_002'>否</font>");
                }else{
                    $("#disRecommend").html("<font class='color_001'>是</font>");
                }
                var front_path="${frontPath}";/**前台项目路径**/
                $("#dPcUrl").html(front_path+"productInfo/"+productInfo.productId+".html"); /**组拼pc的商品访问地址**/
                $("#dWxUrl").html(front_path+"phone/gotoProductInfo.action?productId="+productInfo.productId); /**组拼微信手机的商品访问地址**/
                $("#dvisitNums").html(productInfo.visitNums); /**商品浏览量**/
                $("#d_totalSales").html(productInfo.totalSales); /**商品销售数量**/
                var imgHtml="";
                if(productImgList!=null&&productImgList!=""){
                    for(var i=0;i<productImgList.length;i++){
                        imgHtml+="<img id='uploadImg_detail_"+(i+3)+"' class='uploadImg' onMouseOver='showDetailBigImage("+(i+3)+",3,3,0)'  onMouseOut='showDetailRebackImage("+(i+3)+",1,1)' src='"+"${uploadPath}/"+productImgList[i].thumbnail+"' onerror='this.src=\"${srcPath}/common/images/mrbj.png\"' width='50px' height='50px' style='margin-left:5px;'/>";
                    }
                }else{
                    imgHtml+="/";
                }
                $("#duploadImage").html(imgHtml);

                /**所选的属性的json----start**/
                var jaattrList = data.attrList;
                var htmlAttrStr1="";
                if(jaattrList!=""){
                    if(jaattrList.length>0){
                        htmlAttrStr1+="<tr class='newAdd'><td align='center' colspan='4'>商品属性</td></tr>";
                        for(var i=0;i<jaattrList.length;i++){
                            if((i+1)%2==1){/**当前参数为第奇数个时，追加<tr>标签**/
                                htmlAttrStr1 += "<tr style='line-height: 22px' class='newAdd'>";
                            }
                            htmlAttrStr1+="<td width='19%;' class='toright_td'>"+jaattrList[i].name+":</td>";
                            if(i==(jaattrList.length-1)){
                                htmlAttrStr1+="<td colspan=\"3\" width='81%;' class='toleft_td'>"+jaattrList[i].attrValueName+"</td>"
                            }else{
                                htmlAttrStr1+="<td width='31%;' class='toleft_td'>"+jaattrList[i].attrValueName+"</td>"
                            }
                            if((i+1)%2==0){/**当前参数为第偶数个时，追加</tr>标签**/
                                htmlAttrStr1 += "</tr>";
                            }else{
                                if(i==(jaattrList.length-1)){/**最后一行不够两个参数时，追加</tr>标签**/
                                    htmlAttrStr1 += "</tr>";
                                }
                            }
                        }
                    }
                }
                $("#detailTable").append(htmlAttrStr1);
                /**所选的属性的json----end**/
                /**所选的参数json-----start**/
				var htmlParaStr1="";
				if(productInfo.productParametersValue!=""){
					var prodPara1 = JSON.parse(productInfo.productParametersValue);
					if(prodPara1.length){
						htmlParaStr1+="<tr class='newAdd'><td colspan='4' align='center'>规格参数</td></tr>";
						for(var i=0;i<prodPara1.length;i++){
							htmlParaStr1+="<tr class='newAdd'><td width='136px' class='toright_td'>"+prodPara1[i].name+"</td>";
							htmlParaStr1+="<td colspan='3' class='newAdd'><table style='border-collapse:collapse;border-spacing:0;width:100%;'>";
							var paraInfoValue1=prodPara1[i].paramGroupInfo;
							for(var j=0;j<paraInfoValue1.length;j++){
									var paraInfo_value = '/';
									if(paraInfoValue1[j].value!=''&&paraInfoValue1[j].value!=null){
										paraInfo_value = paraInfoValue1[j].value;
									}
									if((j+1)%2==1){/**当前参数为第奇数个时，追加<tr>标签**/
										htmlParaStr1 += "<tr style='line-height: 22px;' class='newAdd'>";
									}
									htmlParaStr1+="<td class='toright_td' width='25%'>"+paraInfoValue1[j].name+":</td>";
									
									if((j+1)%2==1&&j==(paraInfoValue1.length-1)){
										htmlParaStr1+="<td colspan=\"3\" class='toleft_td' width='75%'>"+paraInfo_value+"</td>";
										
									}else{
										htmlParaStr1+="<td class='toleft_td' width='25%'>"+paraInfo_value+"</td>";
										
									}
									if((j+1)%2==0){/**当前参数为第偶数个时，追加</tr>标签**/
										htmlParaStr1 += "</tr>";
									}else{
										if(j==(paraInfoValue1.length-1)){/**最后一行不够两个参数时，追加</tr>标签**/
											htmlParaStr1 += "</tr>";
										}
									}
							}
							htmlParaStr1+="</table></td>";
							htmlParaStr1+="</tr>";
						}
					}
				}
				$("#detailTable").append(htmlParaStr1);
				/**所选的参数json-----end**/
				var functionDescHtml="";
				if(productInfoDetail.detailContent!=null&&productInfoDetail.detailContent!=""){
					functionDescHtml += "<tr class='newAdd'><td colspan='4' align='center'>商品详情</td></tr>";
					functionDescHtml += "<tr class='newAdd'><td class='toleft_td' colspan='4' class='newAdd'>&nbsp;&nbsp;";
					functionDescHtml += "<span id='detailContentValue' style='width:800px;'>"+productInfoDetail.detailContent+"</span>";
					functionDescHtml += "</td></tr>";
				}
				$("#detailTable").append(functionDescHtml);
			}
		});
	}

</script>
<div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
	<div class="modal-dialog" style="width:70%">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h5 class="modal-title" id="myModalLabel">商品详情</h5>
			</div>
			<div class="modal-body">
				<table id="detailTable" align="center" class="addOrEditTable table table-bordered">
					<tr class="titlebg"><td colspan='4' align='center'>商品信息</td></tr>
					<tr>
						<td class="toright_td" width="150px">商品名称:</td>
						<td class="toleft_td"  width="250px">&nbsp;&nbsp;<span id="dproductName"></span></td>
						<td class="toright_td" width="150px">商品全名称:</td>
						<td class="toleft_td"  width="250px">&nbsp;&nbsp;<span id="dproductFullName"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">商品LOGO:</td>
						<td  class="toleft_td"  width="250px" height="150px">&nbsp;&nbsp;<span id="dsmallPhoto"></span></td>
						<td class="toright_td" width="150px">商品二维码:</td>
						<td  class="toleft_td"  width="250px" height="150px">&nbsp;&nbsp;<span id="dqrCode"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">商品主ID:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dproductId"></span></td>
						<td class="toright_td" width="150px">SKU号:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dsku"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">商品编号:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dproductCode"></span></td>
						<td class="toright_td" width="150px">店铺名称:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dshopName"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">商品所属分类:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dproductTypeName"></span></td>
						<td class="toright_td" width="150px">店铺内部分类:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dshopProCategoryName"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">商品品牌:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dbrandId"></span></td>
						<td class="toright_td" width="150px">库存数:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dstoreNumber"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">市场价格:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dmarketPrice"></span></td>
						<td class="toright_td" width="150px">销售价格:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dsalesPrice"></span></td>
					</tr>
					<tr>
			<!-- 			<td class="toright_td" width="150px">商城赠送积分:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dgiveAwayCoinNumber"></span></td> -->
						<td class="toright_td" width="150px">批发价格:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="salesPriceBack"></span></td> 
						<td class="toright_td" width="150px">条形码:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dbarCode"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">商品浏览量:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dvisitNums"></span></td>
						<td class="toright_td" width="150px">商品销售量:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="d_totalSales"></span></td>
					</tr>

					<tr>
						<td class="toright_td" width="150px">包装规格:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dpackingSpecifications"></span></td>
						<td class="toright_td" width="150px">计量单位:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dmeasuringUnitName"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">制造商型号:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dmanufacturerModel"></span></td>
						<td class="toright_td" width="150px">是否推荐:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="disRecommend"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">是否上架:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="ddisPutSale"></span></td>
						<td class="toright_td" width="150px">上架时间:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dputSaleDate"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">创建时间:</td><td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="d_createDate"></span></td>
						<td class="toright_td" width="150px">更新时间:</td><td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="d_updateDate"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">审核状态:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="disPass"></span></td>
						<td class="toright_td" width="150px">审核备注:</td>
						<td  class="toleft_td" colspan="3">&nbsp;&nbsp;<span id="dauditComment"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">上一级返利:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dupRatio"></span></td>
						<td class="toright_td" width="150px">上二级返利:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dsecRatio"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">上三级返利:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dthiRatio"></span></td>
						<td class="toright_td" width="150px">商品备注:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dnote"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">SEO标题:</td>
						<td  class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dseoTitle"></span></td>
						<td class="toright_td" width="150px">SEO关键字:</td>
						<td class="toleft_td" width="250px">&nbsp;&nbsp;<span id="dseoKeyWord"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">SEO描述:</td>
						<td  class="toleft_td" width="250px" colspan="6">&nbsp;&nbsp;<span id="dseoDescription"></span></td>
					</tr>
					<tr>
						<td class="toright_td" width="150px">商品图片:</td>
						<td  class="toleft_td" colspan="6"  style="line-height: 10px;">&nbsp;&nbsp;<span id="duploadImage"></span></td>
					</tr>
				</table>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal -->
</div>